/*
 * marketsim-eclipsetrader
 *
 * Copyright (C) 2008-2011 Steve Phelps and John Cartlidge
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 */
package victria.marketsim.core;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;

import org.apache.log4j.Logger;

public class DescendingOrderComparator implements Serializable, Comparator<Order> {

	static Logger logger = Logger.getLogger(DescendingOrderComparator.class);
	
	public int compare(Order o1, Order o2) {
		float p1 = o1.getPrice();
		float p2 = o2.getPrice();
		if (p1 < p2) {
			return 1;
		} else {
			if (p1 > p2) {
				return -1;
			} else {	
				Date d1 = o1.getDate();
				Date d2 = o2.getDate();
				return d1.compareTo(d2);
			}
		}
	}

}
